package com.xauto.pioneer.appuser.adapter;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;

import com.xauto.pioneer.appuser.R;
import com.xauto.pioneer.appuser.model.OrderInfo;
import com.xauto.pioneer.appuser.model.ParkSpace;

/**
 * Created by Lemon on 2015/12/11.
 * Desc:网点停车位适配器
 */
public class ParkSpaceAdapter extends AbsAdapter<ParkSpace> {

    public ParkSpaceAdapter(Activity context, int layout) {
        super(context, layout);
    }

    @Override
    public ViewHolder<ParkSpace> getHolder() {
        return new TemplateViewHolder();
    }
    private int currentPosition = -1;

    public void setCurrentPosition(int currentPosition) {
        this.currentPosition = currentPosition;
        notifyDataSetChanged();
    }

    private class TemplateViewHolder implements ViewHolder<ParkSpace> {

        private TextView space_name_text;

        @Override
        public void initViews(View v, int position) {
            space_name_text = (TextView) v.findViewById(R.id.space_name_text);
        }

        @Override
        public void updateData(ParkSpace parkSpace, int position) {
            space_name_text.setText(parkSpace.parking_space_name);
            space_name_text.setBackgroundResource(currentPosition == position ? R.drawable.bg_space_name_press : R.drawable.bg_space_name_normal);
            space_name_text.setTextColor(currentPosition == position ? context.getResources().getColor(R.color.white) : context.getResources().getColor(R.color.driver_color_deep));
        }

        @Override
        public void doOthers(ParkSpace parkSpace, int position) {
//            space_name_text.setText(parkSpace.parking_space_name);
//            space_name_text.setBackgroundResource(R.drawable.bg_space_name_press);
//            space_name_text.setTextColor(context.getResources().getColor(R.color.white));
        }
    }
}
